/*
 * i2c.h
 *
 *  Created on: Jan 13, 2014
 *      Author: ppks
 */

#ifndef I2C_H_
#define I2C_H_

/********************************************************************************/
/* I2C Configuration                                                            */
/********************************************************************************/
#define I2C_CLK_100     100000
#define I2C_CLK_400     400000

#define I2C_CLK_SPEED   I2C_CLK_400

/******************************************************************************/
/* Global Variable Declaration                                                */
/******************************************************************************/
extern uint16_t i2c_errors_count;

/********************************************************************************/
/* Exported Functions Prototypes                                                */
/********************************************************************************/
void CommI2C_Init(void);
void CommI2C_SendRepeatStart(uint8_t addr);
void CommI2C_SendStop(void);
void CommI2C_Write(uint8_t data);
uint8_t CommI2C_Read(uint8_t ack);
uint8_t CommI2C_Read(uint8_t ack);
uint8_t CommI2C_ReadAck(void);
uint8_t CommI2C_ReadNack(void);
void CommI2C_ReadRegToBuffer(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t size);
void CommI2C_WriteReg(uint8_t addr, uint8_t reg, uint8_t val);
uint8_t CommI2C_ReadReg(uint8_t addr, uint8_t reg);

#endif /* I2C_H_ */
